package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Booking;
import models.Vehicle;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class BookingTable {

    public static TableModel create(String current_user) {
        final String PAYER = "|客户付|含车价";
        final String CHECKOUT_TYPE = "|现收|卡开";
        final String WORK_TYPE = "|全班车|半班车|全旅游|半旅游|修车|加油|提车|验车|报道待命";
    
        final String title = "业务预约";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("customer",    "用车客户",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("customer_name",    "订车人",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("customer_phone",    "联系电话",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("passenger_number",    "乘员数",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("start_date",    "用车日期",    true,    today,    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("end_date",    "结束日期",    true,    today,    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("useday_number",    "用车天数",    true,    "",    true,    false,    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("plan_route",    "计划行程",    true,    "",    false,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("vehicle.brand",    "车辆厂牌",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Vehicle.getBrandJson(),    null,  "ONEBOX",  "vehicle",  "brand",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("vehicle_count",    "车辆数",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("set_count",    "座位数",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("stop_place",    "停车地点",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("stopstart_time",    "停车时间",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "datetime",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("stopend_time",    "结束时间",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "datetime",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("limit_mileage",    "额定里程",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("limit_price",    "额定车价",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("parking_fees",    "停车费(估）",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("passroad_fees",    "过路费(估）",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("payer",    "承担方",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(PAYER),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("allowance",    "补贴",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("checkout_type",    "结算方式",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(CHECKOUT_TYPE),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("work_type",    "业务性质",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(WORK_TYPE),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("name",    "承接人",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("check_number",    "核定数",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("comment",    "备注",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("write_date",    "登记日期",    true,    today,    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Booking.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

